# Obtained from: https://github.com/lhoyer/DAFormer
# ---------------------------------------------------------------
# Copyright (c) 2021-2022 ETH Zurich, Lukas Hoyer. All rights reserved.
# Licensed under the Apache License, Version 2.0
# ---------------------------------------------------------------

# model settings
norm_cfg = dict(type='BN', requires_grad=True)
model = dict(
    type='EncoderDecoder',
    pretrained='open-mmlab://resnet50_v1c',
    backbone=dict(
        type='ResNetV1c',
        depth=50,
        num_stages=4,
        out_indices=(0, 1, 2, 3),
        dilations=(1, 1, 2, 4),
        strides=(1, 2, 1, 1),
        norm_cfg=norm_cfg,
        norm_eval=False,
        style='pytorch',
        contract_dilation=True),
    decode_head=dict(
        type='HRDAHead',
        single_scale_head='DAFormerHead',
        in_channels=2048,  # ResNet 输出的通道数，通常是 2048
        channels=256,  # 解码头中的中间通道数，需要显式设置
        in_index=3,  # 选择使用第 4 层输出的特征图
        # dilations=(6, 12, 18, 24),  # 空洞卷积的膨胀因子
        attention_embed_dim=256,  # 注意嵌入维度
        decoder_params=dict(  # 添加 decoder_params
            embed_dims=256,
            fusion_cfg=dict(
                type='aspp',
                norm_cfg=dict(type='BN')
            )
        ),
        num_classes=6,
        align_corners=False,
        init_cfg=dict(
            type='Normal', std=0.01, override=dict(name='aspp_modules')),
        loss_decode=dict(
            type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)),
    # model training and testing settings

    train_cfg=dict(),
    test_cfg=dict(mode='whole'))
